package drds.server.config.model;

import drds.server.route.shard_algorithm.AbstractShardAlgorithm;

/**
 * 分片规则，column是用于分片的数据库物理字段
 */
public class ShardRule {
	private final String columnName;
	private final String shardAlgorithmId;
	private AbstractShardAlgorithm shardAlgorithm;

	public ShardRule(String columnName, String shardAlgorithmId) {

		if (columnName == null || columnName.length() <= 0) {
			throw new IllegalArgumentException("no rule column is found");
		}
		if (shardAlgorithmId == null) {
			throw new IllegalArgumentException("functionName is null");
		}
		this.columnName = columnName;
		this.shardAlgorithmId = shardAlgorithmId;

	}

	public AbstractShardAlgorithm getShardAlgorithm() {
		return shardAlgorithm;
	}

	public void setShardAlgorithm(AbstractShardAlgorithm shardAlgorithm) {
		this.shardAlgorithm = shardAlgorithm;
	}

	public String getColumnName() {
		return columnName;
	}

	public String getShardAlgorithmId() {
		return shardAlgorithmId;
	}

}
